<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="renderer" content="webkit">
  <title>上传文件</title>
  <link href="<@toParam code="PATH"/>/hplus/css/bootstrap.min.css" rel="stylesheet">
  <link href="<@toParam code="PATH"/>/hplus/css/font-awesome.min.css" rel="stylesheet">
	<link href="<@toParam code="PATH"/>/hplus/css/plugins/webuploader/webuploader.css" type="text/css" rel="stylesheet">
  <link href="<@toParam code="PATH"/>/hplus/css/style.min.css" rel="stylesheet">
  <link href="<@toParam code="PATH"/>/hplus/css/hsys.extend.css" rel="stylesheet">
  <style>
		#filePicker .webuploader-pick {border-radius:0 3px 3px 0;display: block;height: 34px;width:80px;font-size: 13px;padding: 0;line-height: 34px;}	
	</style>
</head>

<body>
	<div style="padding:15px">
		<form class="form-horizontal"> 
			<div class="form-group">
				<label class="col-xs-2 control-label" style="text-align: right;padding-top: 7px;">文件路径：</label>
				<div class="col-xs-9">
					<div class="input-group">
				  	<input type="text" class="form-control" id="filepath" readonly="readonly"/>
				    <span class="input-group-btn"><div id="filePicker">选择文件</div></span>
					</div>
				</div>
			</div>
			<div class="form-group">
	    	<div class="col-xs-9 col-xs-offset-2">
	      	<button type="button" onclick="submitPath();" class="btn btn-success">确定</button>
	      </div>
	    </div>
		</form>
	</div>
  <script src="<@toParam code="PATH"/>/hplus/js/jquery.min.js"></script>
  <script src="<@toParam code="PATH"/>/hplus/js/bootstrap.min.js"></script>
  <script src="<@toParam code="PATH"/>/hplus/js/plugins/layer/layer.min.js"></script>
	<script src="<@toParam code="PATH"/>/hplus/js/plugins/webuploader/webuploader.min.js"></script>
  <script src="<@toParam code="PATH"/>/hplus/js/gcore_ext.js"></script>
  <script>
  	var uploader;
  	$(function(){
  		uploader = WebUploader.create({
  			server: 'doUploader',
  			pick: '#filePicker',
  			auto:true,
  			chunked:false,
  			threads:1,
  			fileVal:"filedata",
  			formData:{directory:"${directory!'other'}"}
			});
  		
  		uploader.on( 'fileQueued', function( file ) {
  			layer.load(0, {shade: [0.5,'#fff']});
  		});
  		uploader.on( 'uploadSuccess', function( file,response) {
  			if(response.result=="success"){
  	  		$("#filepath").val(response.savepath);
  			}
  		});
	
			uploader.on( 'uploadComplete', function( file ) {
				layer.closeAll();
			});

	  	uploader.on( 'uploadError', function( file ,reason ) {
	  		layer.alert("上传失败！",{icon:2});
	  	});
  	});
  	
  	function submitPath(){
  		var path = $("#filepath").val();
  		if(path==""){
  			layer.alert("请先选择文件！");
  		}
  		var input = $("#${input!'NULL'}", window.parent.document);
  		if(input.size()>0){
  			input.val(path);
  		}
  		window.parent.layer.closeAll();
  	}
  </script>
</body>
</html>
